package com.atguigu.web.controller;

import com.atguigu.web.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
public class testController {
    /*根据t'y'pe值来返回具体类型的数据*/
    /*http://localhost:8080/hello?type=xml*/
    /*/*http://localhost:8080/hello?type=json*/
    @GetMapping("/hello")
    public User getHell(){
      log.info("controller进来了");
      int i=10/0;
      return new User(1,"jss",14,"先");
    }

    /*public static void main(String[] args) throws JsonProcessingException {
        User user =new User(1,"jss",14,"先");
        YAMLFactory yamlFactory =new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER);
        ObjectMapper mapper =new ObjectMapper(yamlFactory);
        String s = mapper.writeValueAsString(user);
        System.out.println("s = " + s);
    }*/
/*    @ExceptionHandler(Exception.class)*//*exceptionHandler只能处理这个类的错误*//*
//    @ControllerAdvice 统一处理所有的错误
    public String errorController(Exception e){
        return "cuowu"+e.getMessage();
    }*/
}
